package com.farm.chain;

public class SystemFaultHandler implements EmergencyHandler {
    private EmergencyHandler nextHandler;

    @Override
    public void setNextHandler(EmergencyHandler nextHandler) {
        this.nextHandler = nextHandler;
    }

    @Override
    public void handleRequest(EmergencyRequest request, String machineName) {
        if (request.getType().equals("SYSTEM_FAULT")) {
            System.out.println(machineName + "系统故障处理器处理: " + request.getMessage());
            System.out.println(machineName + "执行操作: 紧急停机，通知维修人员");
        } else if (nextHandler != null) {
            nextHandler.handleRequest(request, machineName);
        } else {
            System.out.println("没有处理器能处理此请求: " + request.getMessage());
        }
    }
}
